home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 44 / PC Actual CD 44.iso / Linux / Cygwin / full.exe / Disk1 / data1.cab / Tools / share / tix4.1 / SText.tcl < prev    next >
Encoding:
Text File  |  1998-12-04  |  3.2 KB  |  139 lines

  1. # SText.tcl --
  2. #
  3. #    This file implements Scrolled Text widgets
  4. #
  5. # Copyright (c) 1996, Expert Interface Technologies
  6. #
  7. # See the file "license.terms" for information on usage and redistribution
  8. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  9. #
  10.  
  11.  
  12.  
  13. tixWidgetClass tixScrolledText {
  14.     -classname TixScrolledText
  15.     -superclass tixScrolledWidget
  16.     -method {
  17.     }
  18.     -flag {
  19.     }
  20.     -static {
  21.     }
  22.     -configspec {
  23.     }
  24.     -default {
  25.     {.scrollbar            both}
  26.     {*borderWidth            1}
  27.     {*text.background        #c3c3c3}
  28.     {*text.highlightBackground    #d9d9d9}
  29.     {*text.relief            sunken}
  30.     {*text.takeFocus        1}
  31.     {*Scrollbar.background        #d9d9d9}
  32.     {*Scrollbar.relief        sunken}
  33.     {*Scrollbar.troughColor        #c3c3c3}
  34.     {*Scrollbar.takeFocus        0}
  35.     {*Scrollbar.width        15}
  36.     }
  37.     -forcecall {
  38.     -scrollbar
  39.     }
  40. }
  41.  
  42. proc tixScrolledText:ConstructWidget {w} {
  43.     upvar #0 $w data
  44.     global tcl_platform
  45.  
  46.     tixChainMethod $w ConstructWidget
  47.  
  48.     set data(w:text) \
  49.     [text $w.text]
  50.     set data(w:hsb) \
  51.     [scrollbar $w.hsb -orient horizontal]
  52.     set data(w:vsb) \
  53.     [scrollbar $w.vsb -orient vertical]
  54.  
  55.     if {$data(-sizebox) && $tcl_platform(platform) == "windows"} {
  56.         set data(w:sizebox) [ide_sizebox $w.sizebox]
  57.     }
  58.  
  59.     set data(pw:client) $data(w:text)
  60. }
  61.  
  62. proc tixScrolledText:SetBindings {w} {
  63.     upvar #0 $w data
  64.  
  65.     tixChainMethod $w SetBindings
  66.  
  67.     $data(w:text) config \
  68.     -xscrollcommand "tixScrolledText:XScroll $w"\
  69.     -yscrollcommand "tixScrolledText:YScroll $w"
  70.  
  71.     $data(w:hsb) config -command "$data(w:text) xview"
  72.     $data(w:vsb) config -command "$data(w:text) yview"
  73. }
  74.  
  75. #----------------------------------------------------------------------
  76. #
  77. #        option configs
  78. #----------------------------------------------------------------------
  79. proc tixScrolledText:config-takefocus {w value} {
  80.     upvar #0 $w data
  81.   
  82.     $data(w:text) config -takefocus $value
  83. }    
  84.  
  85. proc tixScrolledText:config-scrollbar {w value} {
  86.     upvar #0 $w data
  87.   
  88.     if {[string match "auto*" $value]} {
  89.     set value "both"
  90.     }
  91.     set data(-scrollbar) $value
  92.  
  93.     tixChainMethod $w config-scrollbar $value
  94.  
  95.     return $value
  96. }    
  97.  
  98. #----------------------------------------------------------------------
  99. #
  100. #        Widget commands
  101. #----------------------------------------------------------------------
  102.  
  103.  
  104. #----------------------------------------------------------------------
  105. #
  106. #        Private Methods
  107. #----------------------------------------------------------------------
  108.  
  109. #----------------------------------------------------------------------
  110. # virtual functions to query the client window's scroll requirement
  111. #----------------------------------------------------------------------
  112. proc tixScrolledText:GeometryInfo {w mW mH} {
  113.     upvar #0 $w data
  114.  
  115.     return [list "$data(x,first) $data(x,last)" "$data(y,first) $data(y,last)"]
  116. }
  117.  
  118. proc tixScrolledText:XScroll {w first last} {
  119.     upvar #0 $w data
  120.  
  121.     set data(x,first) $first
  122.     set data(x,last)  $last
  123.  
  124.     $data(w:hsb) set $first $last
  125.  
  126.     tixWidgetDoWhenIdle tixScrolledWidget:Configure $w
  127. }
  128.  
  129. proc tixScrolledText:YScroll {w first last} {
  130.     upvar #0 $w data
  131.  
  132.     set data(y,first) $first
  133.     set data(y,last)  $last
  134.     
  135.     $data(w:vsb) set $first $last
  136.  
  137.     tixWidgetDoWhenIdle tixScrolledWidget:Configure $w
  138. }
  139.